package com.minis.web.context.deprecated;

import org.dom4j.Element;

import java.util.HashMap;
import java.util.Map;

public class XmlConfigReader {
    public XmlConfigReader() {
    }
    
    public Map<String, MappingValue> loadConfig(Resource res) {
        HashMap<String, MappingValue> mapping = new HashMap<>();

        while (res.hasNext()) {
            Element element = (Element) res.next();
            String beanID = element.attributeValue("id");
            String beanClassName = element.attributeValue("class");
            String beanMethod = element.attributeValue("value");

            mapping.put(beanID, new MappingValue(beanID, beanClassName, beanMethod));
        }

        return  mapping;
    }
}
